#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 3, M = 1e6 + 3;

//fixed data
int n, m, l, V;
int p[N];
int d[N], v[N], a[N];

//individual data
int ans1, ans2;
int p_max, l_min;
vector < pair<int, int> > vec1, vec2;
bool f[N];
bool cmp(pair<int, int> p1, pair<int, int> p2) {
    return p1.first < p2.first;
}

//real main
void solve() {
    //fixed input
    scanf("%d%d%d%d", &n, &m, &l, &V);
    for (int i  = 1; i <= n; ++i) {
        scanf("%d%d%d", &d[i], &v[i], &a[i]);
    }
    for (int i = 1; i <= m; ++i) {
        scanf("%d", &p[i]);
        p_max = max(p[i], p_max);
    }

    //individual execute
    for (int i = 1; i <= n; ++i) {
        if (a[i] == 0) {
            if (v[i] > V && d[i] <= p_max) {
                ans1++;
                vec1.push_back(make_pair(d[i], m));
            }
        }
        else if (a[i] > 0) {
            double dirta_x = (V * V - v[i] * v[i]) / (2 * a[i]);
            double x = d[i] + max(dirta_x, 0.0);
            if (x <= (double)p_max) {
                ans1++;
                x -= 1;
                int tmp = upper_bound(p + 1, p + 1 + m, x - 1) - p;
                l_min = min(l_min, tmp);
            }
        }
        else {
            double dirta_x = (V * V - v[i] * v[i]) / (2 * a[i]);
            int l = upper_bound(p + 1, p + 1 + m, d[i] - 1) - p;
            int r = lower_bound(p + 1, p + 1 + m, d[i] + dirta_x + 1) - p - 1;
            if (l <= r) {
                ans1++;
                vec1.push_back(make_pair(l, r));
            }
            //cout << d[i] << ' ' << d[i] + dirta_x << ' ' << l << ' ' << r << endl;
        }
    }
    if (l_min != M) vec1.push_back(make_pair(l_min, m));

    for (int i = 0; i < vec1.size(); ++i) {
        if (!f[i]) continue;
        for (int j = 0; j < vec1.size(); ++j) {
            if (i == j || !f[j]) continue;
            int li = vec1[i].first, ri = vec1[i].second;
            int lj = vec1[j].first, rj = vec1[j].second;
            if (li >= lj && ri <= rj) f[j] = 0;
        }
    }

    for (int i = 0; i < vec1.size(); ++i) {
        if (f[i]) vec2.push_back(vec1[i]);
    }
    sort(vec2.begin(), vec2.end(), cmp);

    int ma = 0, cnt = 0;
    for (auto &i : vec2) {
        //cout << i.first << ' ' << i.second << endl;
        if (i.first > ma) {
            cnt++;
            ma = i.second;
        }
    }
    printf("%d %d\n", ans1, m - cnt);
    //cout << endl;
}
int main() {
    freopen("detect.in", "r", stdin);
    freopen("detect.out", "w", stdout);
    //fixed input
    int T;
    scanf("%d", &T);
    while (T--) {
        ans1 = 0, ans2 = 0, p_max = 0, l_min = M;
        vec1.clear();
        vec2.clear();
        memset(f, 1, sizeof f);
        solve();
    }
    return 0;
}

//80
